import request from '@/utils/request'

// 查询Supplier列表
export function listSupplier(query) {
  return request({
    url: '/Supplier/list',
    method: 'get',
    params: query
  })
}

// 查询Supplier详细
export function getSupplier(supplierCode) {
  return request({
    url: '/Supplier/' + supplierCode,
    method: 'get'
  })
}

// 新增Supplier
export function addSupplier(data) {
  return request({
    url: '/Supplier',
    method: 'post',
    data: data
  })
}

// 修改Supplier
export function updateSupplier(data) {
  return request({
    url: '/Supplier',
    method: 'put',
    data: data
  })
}

// 删除Supplier
export function delSupplier(supplierCode) {
  return request({
    url: '/Supplier/' + supplierCode,
    method: 'delete'
  })
}

//根据用户名获取供货商详细信息
export function getSupplierByUsername(username) {
  return request({
    url: '/Supplier/getSupplierByUsername',
    method: 'post',
    data: username,
  })
}

//根据供货商名称获取供货商编码
export function getSupplierCodeByCompanyName(companyName) {
  console.log("调用接口，参数 companyName:", companyName);
  return request({
    url: '/Supplier/getSupplierCodeByCompanyName',
    method: 'post',
    data: companyName, // 直接传递字符串
  })
}
